package types

import "fmt"

type person struct {
	name string
	age  int
}

func MakeStruct() {

	fmt.Printf("初始化一个结构person: %v \n", person{"Bob", 20})

	fmt.Printf("初始化一个结构person: %v \n", person{name: "Alice", age: 30})

	fmt.Printf("初始化一个结构person: %v \n", person{name: "Fred"})

	fmt.Printf("初始化一个结构person并查看这个结构的指针: %q \n", &person{name: "Ann", age: 40})

	s := person{name: "Sean", age: 40}

	fmt.Println(s.name)
	// copy the value of s, change b will not effect to s.
	b := s
	b.name = "Collin"
	fmt.Println(s.name)
	fmt.Println(b.name)
	// refer to address of s, change sp will effect to s.
	sp := &s

	fmt.Println(sp.age)

	sp.age = 51
	fmt.Println(sp.age)
	fmt.Println(s.age)
}
